package com.wabbei.friendcenter.action;

import java.util.List;

import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
import com.webbei.friendcenter.service.MyFriendCenter;
import com.webbei.pojo.Customcomment;
import com.webbei.pojo.Customer;
import com.webbei.pojo.Customs;
import com.webbei.pojo.LoveCar;
import com.webbei.pojo.Orders;
import com.webbei.pojo.Userhot;

public class getFriendOwnMessageAction extends ActionSupport {
		private static final long serialVersionUID = 1L;
		private String uname;
		private MyFriendCenter friservice;
		private Customer customer;
		private Userhot userhot;
		private List<LoveCar> lovecars;
		private int customerID;
		private List<Userhot> hisfriends;
		private List<Orders> customs;
		private List<Orders> customsShare;
		private int state;// is friend? 1:yes 0:no
		private String sessionInName;// the comment people
		
		public String getSessionInName() {
			return sessionInName;
		}
		public void setSessionInName(String sessionInName) {
			this.sessionInName = sessionInName;
		}
		public int getState() {
			return state;
		}
		public void setState(int state) {
			this.state = state;
		}
		/*public List<Customs> getCustomsShare() {
			return customsShare;
		}
		public void setCustomsShare(List<Customs> customsShare) {
			this.customsShare = customsShare;
		}*/
		
		private int customsSize;
		public List<Orders> getCustomsShare() {
			return customsShare;
		}
		public void setCustomsShare(List<Orders> customsShare) {
			this.customsShare = customsShare;
		}

		private List<Customcomment> custComments;
		private int commentSize;
		
		
		public List<Customcomment> getCustComments() {
			return custComments;
		}
		public void setCustComments(List<Customcomment> custComments) {
			this.custComments = custComments;
		}
		public int getCommentSize() {
			return commentSize;
		}
		public void setCommentSize(int commentSize) {
			this.commentSize = commentSize;
		}
		public List<Customcomment> getCustComment() {
			return custComments;
		}
		public void setCustComment(List<Customcomment> custComments) {
			this.custComments = custComments;
		}
		public int getCustomsSize() {
			return customsSize;
		}
		public void setCustomsSize(int customsSize) {
			this.customsSize = customsSize;
		}
		
		/*public List<Customs> getCustoms() {
			return customs;
		}
		public void setCustoms(List<Customs> customs) {
			this.customs = customs;
		}*/
		
		public List<Userhot> getHisfriends() {
			return hisfriends;
		}
		public List<Orders> getCustoms() {
			return customs;
		}
		public void setCustoms(List<Orders> customs) {
			this.customs = customs;
		}
		public void setHisfriends(List<Userhot> hisfriends) {
			this.hisfriends = hisfriends;
		}
		public List<LoveCar> getLovecar() {
			return lovecars;
		}
		public void setLovecar(List<LoveCar> lovecars) {
			this.lovecars = lovecars;
		}
		public Userhot getUserhot() {
			return userhot;
		}
		public void setUserhot(Userhot userhot) {
			this.userhot = userhot;
		}
		public Customer getCustomer() {
			return customer;
		}
		public void setCustomer(Customer customer) {
			this.customer = customer;
		}
		public MyFriendCenter getFriservice() {
			return friservice;
		}
		public void setFriservice(MyFriendCenter friservice) {
			this.friservice = friservice;
		}
		public String getUname() {
			return uname;
		}
		public void setUname(String uname) {
			this.uname = uname;
		}
		
		public int getCustomerID() {
			return customerID;
		}
		public void setCustomerID(int customerID) {
			this.customerID = customerID;
		}
		public List<LoveCar> getLovecars() {
			return lovecars;
		}
		public void setLovecars(List<LoveCar> lovecars) {
			this.lovecars = lovecars;
		}
		public String execute(){
			//sessionInName=ActionContext.getContext().getSession().get("");
			sessionInName="chenhao";
			customerID=friservice.getCustomerIDByUserName(uname);
			customer=friservice.getCustomerByUserName(uname);
			userhot=friservice.getUserhotByUserName(uname);
			lovecars=friservice.getLoveCarsbyUserID(customerID);
			String carBrind=lovecars.get(0).getUsersCarBrind();//the car carBrind
			if(carBrind==null||carBrind==""){
				hisfriends=friservice.getAllFriendsByUserName(uname);
			}else{
				hisfriends=friservice.getAllFriendsByUserNameOrderBycarBrind(uname,carBrind);
			}
			customs=friservice.getAllcustomsByUserName(uname);
			customsShare=friservice.getAllcustomsShareByUserName(uname);
			ActionContext.getContext().put("customsSharecount", customsShare.size());
			customsSize=customs.size();
			custComments=friservice.getAllCommentByUsername(uname);
			commentSize=custComments.size();
			if(sessionInName.equals(uname)){
				state=1;
			}else{
				state=friservice.UnameIsSessionNameFriend(sessionInName,uname);
			}
			return SUCCESS;
		}
		
}
